package com.lanou.myapp.book.boybook.contentboybook;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.toolbox.ImageLoader;
import com.lanou.myapp.R;
import com.lanou.myapp.imageloader.VolleySingleton;

import java.util.List;

/**
 * Created by dllo on 16/1/21.
 */
public class BoyBookAdapter extends RecyclerView.Adapter<BoyBookAdapter.MyViewHolder>{
    private Context context;
    private List<ContentBoyBookBeans.DataEntity.SameRecommendEntity> data;


    public BoyBookAdapter(Context context) {
        this.context = context;
    }

    public void addData(List<ContentBoyBookBeans.DataEntity.SameRecommendEntity> data) {
        this.data = data;
        notifyDataSetChanged();
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_content_boy_book,null);
        MyViewHolder myViewHolder = new MyViewHolder(view);
        return myViewHolder;
    }


    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.textView.setText(data.get(position).getBookName());

//        ImageLoader.ImageListener listener = ImageLoader.getImageListener(holder.imageView, R.mipmap.v6_icon_daily_reading, R.mipmap.v6_icon_daily_reading);
//        VolleySingleton.getImageLoader().get("", listener);
    }


    @Override
    public int getItemCount() {
        return data.size() > 0 && data != null ? data.size() : 0;
    }


    class MyViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView;
        private TextView textView;

        public MyViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.iv_content_same_boy_book);
            textView = (TextView) itemView.findViewById(R.id.tv_content_same_boy_book);
        }
    }


}
